#include<bits/stdc++.h>

using namespace std;

int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	int n;
	list<int> f;
	cin>>n;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		f.push_back(i*10+t);
	}
	while (!f.empty()){
		int t=2;
		vector<list<int>::iterator> era;
		for(list<int>::iterator i=f.begin();i!=f.end();){
			if((*i)%10!=t){
				cout<<(*i)/10<<" ";
				era.push_back(i);
			}
			t=(*i)%10;
			i++;
		}
		for(int i=0;i<era.size();i++){
			f.erase(era[i]);
		}
		cout<<endl;
	}
	return 0;
}
